<script type="text/javascript">
jQuery(function($) {
	$('#datatable').dataTable({
		'bJQueryUI': true,
		'sPaginationType': 'full_numbers'
	});
	
	 if(jQuery("#nortify").css('display')!= 'none'){
        jQuery("#nortify").fadeOut(4000);
	 }
	 
});

jQuery(function($){
	$("#btn_add_new_hotel").click(function(){
	   window.location.replace("/admin/city/edit/0");
	});
});

function delete_confirmation(facility_id){
	var res=confirm("Are you sure you want to delete this city?"); 
	if(res==true){
		window.location.replace("/admin/city/delete/"+facility_id);
	}
}
 
</script>

<section id="content">
	<section class="container_12 clearfix">
		<section id="main" class="grid_12">
			<article class="content">
		    <?
				if(isset($message_id)){
					switch($message_id){
						case true:{
							echo '<div id="nortify" style="display:block;" class="success msg">The city has been deleted successfully.</div>';
						}break;
						case false:{
							echo '<div id="nortify" style="display:block;" class="error msg">An error has occured while deleting.</div>';
						}break;
					}
				} 
			?>
			   
              <ul style="list-style:none;float:left;">
              	<li style="float:left;">
                	<h2>City List</h2></li>
                <li style="float:left;">
                	<button id="btn_add_new_hotel" style="margin-left: 10px;margin-top: 20px;" type="button" class="button">Add New City</button></li>
              </ul>
                <table id="table1" class="gtable sortable">
                    <thead>
                        <tr> 
                        <th>City ID</th>
                        <th>Name</th>  
                        <th>Latitude</th>
                        <th>Longitude</th>
                        <th>Distancec From Colombo</th>
                        <th>Is Enabled</th>
                        <th>Edit</th>
                        </tr>
                    </thead>
                    <tbody> 
                    <?
                    foreach($hotel_city_list as $city){?> 
                    <tr class="gradeA odd">
                        <td><?=$city->id?></td>
                        <td><?=$city->name?></td>  
                        <td class="center"><?=$city->latitude?></td>
                        <td class="center"><?=$city->longitude?></td>
                        <td class="center"><?=number_format($city->distance_from_colombo,2)?></td>
                         
                        <td class="center"><?
							switch($city->is_enabled){
								case 1:{echo 'Yes';}break;
								case 0:{echo 'No';}break; 
							}
						 ?></td>  
                            <td> 
                                <img class="move" src="/images/icons/arrow-move.png" alt="Move" title="Move" border="0" />
                                <a href="/admin/city/edit/<?=$city->id?>" title="Edit"><img src="/images/icons/edit.png" alt="Edit" border="0" /></a>
                                <a href="#" title="Delete"><img onclick="javascript:delete_confirmation('<?=$city->id?>');" src="/images/icons/cross.png" alt="Delete" border="0" /></a>
                            </td>
                        </tr>
                     <? } ?>
                    </tbody>
                </table>
			</article>
		</section>
	</section>
</section>
 